﻿package template1
{
	import flash.text.TextField;
	import flash.events.Event;
	import flash.text.TextFieldType;
	import flash.text.TextFormat;
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	
	public class MainScreen extends MovieClip
	{
		private var bgImage:Image	
		private var iconImage:Image;
		private var textContent:TextField;
		private var image:Image;
		private var ok:Image;
		private var cancel:Image;
		public function MainScreen()
		{
			//trace("MainScreen w "+this.width+" h "+this.height);
			this.x=0;
			this.y=0;
				
			bgImage = new Image();
			bgImage.bitmap = Icons.BACKGROUND_MAIN_ENGLISH;
			this.addChild(bgImage);
			bgImage.x = 0;
			bgImage.y = 0;
			
			textContent=new TextField();
			textContent.x = 0//228;//228;
			textContent.y = 275//102; //216;
			textContent.width=750//340;
			textContent.height=150;
			textContent.selectable=false;
			textContent.type=TextFieldType.DYNAMIC;
			textContent.multiline = true
			textContent.wordWrap = true;
			textContent.defaultTextFormat = new TextFormat("Ubuntu" ,18,null,null,null,null,null,null,"center");
			textContent.embedFonts=true;
			this.addChild(textContent);
			
			
			iconImage=new Image();
			iconImage.x = 300;//350;
			iconImage.y = 40;//102;
			iconImage.dimension(198,198);
			this.addChild(iconImage);
			
			
			
			image=new Image();
			image.x=300//350;
			image.y=330//380;
			image.dimension(198,198);
			this.addChild(image);
			
			ok=new Image();
			ok.x=283;
			ok.y =546 //514;
			ok.buttonMode = true;
			ok.useHandCursor = true;
			ok.addEventListener(MouseEvent.CLICK,handleOK);
			this.addChild(ok);
			ok.bitmap=Icons.OK_ENGLISH;
			
			cancel=new Image();
			cancel.x=417;
			cancel.y =546// 514;
			cancel.buttonMode = true;
			cancel.useHandCursor = true;
			cancel.addEventListener(MouseEvent.CLICK,handleCANCEL);
			this.addChild(cancel);
			cancel.bitmap=Icons.CANCEL_ENGLISH;
		}
		public static const OK:String="ok";
		public static const CANCEL:String="cancel";
		private function handleOK(event:MouseEvent):void
		{
			dispatchEvent(new Event(OK));
		}
		
		private function handleCANCEL(event:MouseEvent):void
		{
			dispatchEvent(new Event(CANCEL));
		}
		
		public function set contentText(str:String):void
		{
			textContent.text=str;
			/*if (textContent.textHeight < textContent.height)
			{
				textContent.height = textContent.textHeight+5 ;
				//textContent.y = 214 + (156 - textContent.height) / 2;
				textContent.y = 214 + (156 - textContent.height) / 2;
			}*/
			
			if (textContent.textWidth < textContent.width)
			{
				textContent.width = textContent.textWidth +5
				textContent.x = (800 - textContent.textWidth) / 2;
			}

		}
		public function set iconImageUrl(url:String):void
		{
			iconImage.url=url;
		}

		public function set imageUrl(url:String):void
		{
			image.url=url;
		}
	}
	
}
